import pymysql

def main():
    no = int(input('要编辑的部门编号：'))
    loc = input('部门新地址：')
    # 获取数据库对象
    conn = pymysql.connect(
        host='localhost',
        port=3306,
        user='root',
        password='123456',
        db='hrs',
        charset='utf8mb4'

    )
    try:
        with conn.cursor() as cursor:
            cursor.execute(
                'select dno,dname,dloc from tb_dept')
            # print(cursor.fetchall())

            for row in cursor.fetchall():
                print(f'部门编号：{row[0]}')
                print(f'部门名称：{row[1]}')
                print(f'部门地址：{row[2]}')
                print('-' * 20)



    except pymysql.MySQLError as error:
        print(error)

    finally:
        conn.close()


    print(conn)


if __name__ == '__main__':
    main()